package com.ant.my.camera;

import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.ant.my.camera.activities.AntIntentCamera;
import com.ant.my.camera.activities.ApkActivity;
import com.ant.my.camera.activities.MyCameraActivity;
import com.ant.my.camera.activities.SurfaceDemoActivity;
import com.ant.my.camera.base.BaseActivity;
import com.ant.my.camera.utils.AntLog;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends BaseActivity {
    private ListView mlv;
    private List<String> slist;
    private List<Class> clist;
    private String packagerName = "";

    @Override
    public int getContentLayout() {
        slist = new ArrayList<>();
        clist = new ArrayList<>();
        packagerName = this.getPackageName();
        return R.layout.ac_main;
    }

    @Override
    public void initView() {
        mlv = (ListView) findViewById(R.id.ac_main_listview);
    }

    @Override
    public void initData() {
        slist.add("camera");
        clist.add(MyCameraActivity.class);
        slist.add("Intent");
        clist.add(AntIntentCamera.class);
        slist.add("apk dir");
        clist.add(ApkActivity.class);
        slist.add("surface demo");
        clist.add(SurfaceDemoActivity.class);


        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, slist);
        mlv.setAdapter(adapter);
    }

    @Override
    public void initListener() {
        mlv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
                Intent in = new Intent(MainActivity.this, clist.get(position));
                MainActivity.this.startActivity(in);
                AntLog.i(TAG, "package==" + packagerName);
            }
        });
    }
}
